/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package hojano6;

/**
 *
 * @author Magaly
 */
public class ArbolHuffman implements Comparable <ArbolHuffman> {
    
     protected BinaryTree <Nodo> empty;
    // raiz del Ã¡rbol.
    protected BinaryTree <Nodo> root;
    // peso del Ã¡rbol
    protected int totalWeight;
    

     public ArbolHuffman (Nodo e){
        this.root= new ImplementacionBinaryT  <Nodo> (e);
        this.totalWeight=e.frequency;
    } 
    
    public  ArbolHuffman (ArbolHuffman left, ArbolHuffman right){
        this.empty = null;
        this.totalWeight = left.totalWeight + right.totalWeight;
        this.root = new ImplementacionBinaryT  <Nodo>(new Nodo(totalWeight),left.root,right.root); 
    }

    public BinaryTree<Nodo> getRoot() {
        return root;
    }

    public void setRoot(BinaryTree<Nodo> root) {
        this.root = root;
    }
    
    @Override
    public int compareTo(ArbolHuffman o) {
        return this.root.value().compareTo(o.root.value());
    }
    
    public boolean equals (ArbolHuffman that){
        if (this.compareTo(that)==0){
            return true;
        }else{
            return false;
        }
    }
 
    
}
